#include<iostream>
using namespace std;
int n,L,R;
int main(){
    cin>>n>>L>>R;
    if(R-L>=n)cout<<n-1;
    else{
        int Ll = L%n,Rl = R%n;
        if (Ll>Rl)cout<<n-1;
        else cout<<Rl;
    } 
    return 0;
}